package it.avantsoft.ls.gl.message;

import java.io.DataOutputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: blackmore
 * Date: 23-lug-2008
 * Time: 18.03.55
 * To change this template use File | Settings | File Templates.
 */
public class AckHorizontalBalanceMessage extends GroupLeaderMessage {
    private String exchangeablePeer;
    private String designedGroupLeaderHost;
    private int designedGroupLeaderListeningPort;

    public AckHorizontalBalanceMessage(DataOutputStream out, String exchangeablePeer, String designedGroupLeaderHost, int designedGroupLeaderListeningPort) {
        super(out);

        this.exchangeablePeer = exchangeablePeer;
        this.designedGroupLeaderHost = designedGroupLeaderHost;
        this.designedGroupLeaderListeningPort = designedGroupLeaderListeningPort;
    }

    public boolean send() {
        boolean sent = false;
        try {
            writeByte(ACKHORIZONTALBALANCEMESSAGE);
            writeUTF(exchangeablePeer);
            writeUTF(designedGroupLeaderHost);
            writeInt(designedGroupLeaderListeningPort);
            flush();
            sent = true;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return sent;  //To change body of implemented methods use File | Settings | File Templates.
    }


    public String toString() {
        return "AckHorizontalBalanceMessage{" +
                "exchangeablePeer='" + exchangeablePeer + '\'' +
                ", designedGroupLeaderHost='" + designedGroupLeaderHost + '\'' +
                ", designedGroupLeaderListeningPort=" + designedGroupLeaderListeningPort +
                '}';
    }
}
